﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;

namespace TY.SoketClient
{
    public class PackageManager
    {
        public Action ReceiveEvent=

        public Action OutEvent
             
        public PackageManager()
        {
            if (QueryList==null)
            {
                QueryList = new Queue<BasicMessage>();
            }
        }
        public static Queue<BasicMessage> QueryList = new Queue<BasicMessage>();
        public Func<BasicMessage> PoP = Popup;
        public Func<int> Count = GetCount;
        public Action<BasicMessage> Push = PushData;
        public Action<BasicMessage> Clear = ClearData;

        private static void ClearData(BasicMessage obj)
        {
            lock (QueryList)
            {
                QueryList.Clear();
            }
        }

        private static int GetCount()
        {
            lock (QueryList)
            {
                return QueryList.Count();
            }
            
        }

       

        

        private static void PushData(BasicMessage obj)
        {
          
            lock (QueryList)
            {
                
                    QueryList.Enqueue(obj);
                
            }

        }

        private static BasicMessage Popup()
        {
            lock (QueryList)
            {
                return QueryList.Dequeue();
            }

        }



    }
}
